package com.pr.makfilm.domain;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * Created with IntelliJ IDEA.
 * User: Pawel
 * Date: 17.09.13
 * Time: 21:19
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "room")
public class Room extends IdentifiableEntity
{
   public static final String FIELD_NAME = "name";

   public static final String FIELD_STREET = "street";

   public static final String FIELD_ZIP = "zip";

   public static final String FIELD_CITY = "city";

   public static final String FIELD_CAPACITY = "capacity";

   public static final String FIELD_LEASE_PRICE = "leasePrice";

   public static final String FIELD_CONTACT_FIRST_NAME = "contactFirstName";

   public static final String FIELD_CONTACT_LAST_NAME = "contactLastName";

   public static final String FIELD_PHONE = "phone";

   public static final String FIELD_MOBILE = "mobile";

   public static final String FIELD_EMAIL = "email";

   public static final String FIELD_TAX_ID = "taxId";

   public static final String FIELD_USER = "user";

   public static final String FIELD_ROW_COUNT = "rowCount";

   public static final String FIELD_COLUMN_COUNT = "columnCount";

   public static final String FIELD_X_STYLE = "xStyle";

   public static final String FIELD_Y_STYLE = "yStyle";

   public static final String FIELD_X_ORDER = "xOrder";

   public static final String FIELD_Y_ORDER = "yOrder";

   public static final String FIELD_NUMBER_RULES = "numberRules";

   public static final int MAX_LENGTH_NAME = 50;

   public static final int MAX_LENGTH_STREET = 35;

   public static final int MAX_LENGTH_ZIP = 6;

   public static final int MAX_LENGTH_CITY = 30;

   public static final int MAX_LENGTH_FIRST_NAME = 25;

   public static final int MAX_LENGTH_LAST_NAME = 35;

   public static final int MAX_LENGTH_PHONE = 9;

   public static final int MAX_LENGTH_EMAIL = 35;

   public static final int MAX_LENGTH_TAX_ID = 10;

   @Id
   @GeneratedValue
   @Column
   private Long id;

   @Column(nullable = false, length = MAX_LENGTH_NAME)
   @NotNull
   @Length(max = MAX_LENGTH_NAME)
   private String name;

   @Column(nullable = false, length = MAX_LENGTH_STREET)
   @NotNull
   @Length(max = MAX_LENGTH_STREET)
   private String street;

   @Column(nullable = false, length = MAX_LENGTH_ZIP)
   @NotNull
   @Length(max = MAX_LENGTH_ZIP)
   private String zip;

   @Column(nullable = false, length = MAX_LENGTH_CITY)
   @NotNull
   @Length(max = MAX_LENGTH_CITY)
   private String city;

   @Column(nullable = true)
   private Integer capacity;

   @Column(name = "lease_price", nullable = true)
   private Double leasePrice;

   @Column(name = "contact_first_name", nullable = true, length = MAX_LENGTH_FIRST_NAME)
   @Length(max = MAX_LENGTH_FIRST_NAME)
   private String contactFirstName;

   @Column(name = "contact_last_name", nullable = true, length = MAX_LENGTH_LAST_NAME)
   @Length(max = MAX_LENGTH_LAST_NAME)
   private String contactLastName;

   @Column(nullable = true, length = MAX_LENGTH_PHONE)
   @Length(max = MAX_LENGTH_PHONE)
   private String phone;

   @Column(nullable = true, length = MAX_LENGTH_PHONE)
   @Length(max = MAX_LENGTH_PHONE)
   private String mobile;

   @Column(nullable = true, length = MAX_LENGTH_EMAIL)
   @Length(max = MAX_LENGTH_EMAIL)
   @Email
   private String email;

   @Column(name = "tax_id", nullable = true, length = MAX_LENGTH_TAX_ID)
   @Length(max = MAX_LENGTH_TAX_ID)
   private String taxId;

   @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY)
   @JoinColumn(nullable = false)
   @NotNull
   private User user;

   @Column(name = "column_count", nullable = false)
   @NotNull
   private Integer columnCount;

   @Column(name = "row_count", nullable = false)
   @NotNull
   private Integer rowCount;

   @Column(name = "x_order", nullable = false)
   @Enumerated(value = EnumType.STRING)
   private NumberOrderEnum xOrder;

   @Column(name = "y_order", nullable = false)
   @Enumerated(value = EnumType.STRING)
   private NumberOrderEnum yOrder;

   @Column(name = "x_style", nullable = false)
   @Enumerated(value = EnumType.STRING)
   private NumberStyleEnum xStyle;

   @Column(name = "y_style", nullable = false)
   @Enumerated(value = EnumType.STRING)
   private NumberStyleEnum yStyle;

//   @Column(name = "number_rules", nullable = false)
//   @Enumerated(value = EnumType.STRING)
//   private NumberRulesEnum numberRules;

   public Long getId()
   {
      return id;
   }

   public void setId(Long id)
   {
      this.id = id;
   }

   public String getName()
   {
      return name;
   }

   public void setName(String name)
   {
      this.name = name;
   }

   public String getStreet()
   {
      return street;
   }

   public void setStreet(String street)
   {
      this.street = street;
   }

   public String getZip()
   {
      return zip;
   }

   public void setZip(String zip)
   {
      this.zip = zip;
   }

   public String getCity()
   {
      return city;
   }

   public void setCity(String city)
   {
      this.city = city;
   }

   public Integer getCapacity()
   {
      return capacity;
   }

   public void setCapacity(Integer capacity)
   {
      this.capacity = capacity;
   }

   public Double getLeasePrice()
   {
      return leasePrice;
   }

   public void setLeasePrice(Double leasePrice)
   {
      this.leasePrice = leasePrice;
   }

   public String getContactFirstName()
   {
      return contactFirstName;
   }

   public void setContactFirstName(String contactFirstName)
   {
      this.contactFirstName = contactFirstName;
   }

   public String getContactLastName()
   {
      return contactLastName;
   }

   public void setContactLastName(String contactLastName)
   {
      this.contactLastName = contactLastName;
   }

   public String getPhone()
   {
      return phone;
   }

   public void setPhone(String phone)
   {
      this.phone = phone;
   }

   public String getMobile()
   {
      return mobile;
   }

   public void setMobile(String mobile)
   {
      this.mobile = mobile;
   }

   public String getEmail()
   {
      return email;
   }

   public void setEmail(String email)
   {
      this.email = email;
   }

   public String getTaxId()
   {
      return taxId;
   }

   public void setTaxId(String taxId)
   {
      this.taxId = taxId;
   }

   public User getUser()
   {
      return user;
   }

   public void setUser(User user)
   {
      this.user = user;
   }

   public Integer getColumnCount()
   {
      return columnCount;
   }

   public void setColumnCount(Integer columnCount)
   {
      this.columnCount = columnCount;
   }

   public Integer getRowCount()
   {
      return rowCount;
   }

   public void setRowCount(Integer rowCount)
   {
      this.rowCount = rowCount;
   }

   public NumberOrderEnum getxOrder()
   {
      return xOrder;
   }

   public void setxOrder(NumberOrderEnum xOrder)
   {
      this.xOrder = xOrder;
   }

   public NumberOrderEnum getyOrder()
   {
      return yOrder;
   }

   public void setyOrder(NumberOrderEnum yOrder)
   {
      this.yOrder = yOrder;
   }

   public NumberStyleEnum getxStyle()
   {
      return xStyle;
   }

   public void setxStyle(NumberStyleEnum xStyle)
   {
      this.xStyle = xStyle;
   }

   public NumberStyleEnum getyStyle()
   {
      return yStyle;
   }

   public void setyStyle(NumberStyleEnum yStyle)
   {
      this.yStyle = yStyle;
   }

//   public NumberRulesEnum getNumberRules()
//   {
//      return numberRules;
//   }
//
//   public void setNumberRules(NumberRulesEnum numberRules)
//   {
//      this.numberRules = numberRules;
//   }

//   public String getRowHeaders()
//   {
//      return rowHeaders;
//   }
//
//   public void setRowHeaders(String rowHeaders)
//   {
//      this.rowHeaders = rowHeaders;
//   }
//
//   public String[] getHeaders()
//   {
//      return StringUtils.split(rowHeaders, ',');
//   }

//   public void setHeaders(String[] headers)
//   {
//      StringBuilder builder = new StringBuilder();
//      if (headers != null)
//      {
//         builder.append(headers[0]);
//         int len = headers.length;
//         if (len > 1)
//         {
//            for (int i = 1; i < len; i++)
//            {
//               builder.append(",");
//               builder.append(headers[i]);
//            }
//         }
//      }
//      rowHeaders = builder.toString();
//   }
}
